#ifndef _LOG_H_
#define _LOG_H_

#include <iostream>
#include <ctime>

#define Debug 0
#define Notice 1
#define Warning 2
#define Error 3

const std::string tip[] ={
        "Debug",
        "Notice",
        "Warning",
        "Error"};

std::ostream &Log(std::string message, int option)
{
    // 获取时间戳 time_t timestamp; time(timestamp);
    time_t timestamp = time(nullptr);
    if (timestamp == std::time_t(-1))
    {
        std::cerr << "获取时间失败" << std::endl;
        exit(1);
    }

    // 获取格式化时间 tm *localtime(const time_t *__timer)
    tm *timeinfo = std::localtime(&timestamp);

    std::cout << " | "
              << 1900 + timeinfo->tm_year << "-"
              << 1 + timeinfo->tm_mon << "-"
              << timeinfo->tm_mday << " "
              << timeinfo->tm_hour << ":"
              << timeinfo->tm_min << ":"
              << timeinfo->tm_sec
              << " | "
              << tip[option]
              << " | "
              << message;

    return std::cout;
}

#endif